home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Games / Pentominoes 2.0 / Pent code / pent endgame.c < prev    next >
C/C++ Source or Header  |  1995-07-29  |  2KB  |  77 lines

  1. #include "pent endgame.h"
  2. #include "pent graphics.h"
  3. #include "pent main window.h"
  4. #include "pent globals.h"
  5. #include "dialog layer.h"
  6. #include "sound layer.h"
  7. #include "window layer.h"
  8. #include "Horizontal bars wipe.h"
  9.  
  10. #define kWinAlertColor    200
  11. #define kWinAlertBW        201
  12.  
  13. void WinGame(WindowRef theWindow)
  14. {
  15.     short            theDepth, i, j, k, refreshIndex;
  16.     MyOffscreenPtr    offscreenWorldPtr;
  17.     WindowPtr        offscreenWindowPtr;
  18.     MyBoardRec        theBoard;
  19.     Point            refresh[12][5];
  20.     Rect            boundsRect;
  21.     
  22.     if (gGraphicEffects)
  23.     {
  24.         HideCursor();
  25.         theDepth=GetWindowDepth(theWindow);
  26.         offscreenWorldPtr=GetWindowPermanentOffscreenWorld(theWindow);
  27.         offscreenWindowPtr=offscreenWorldPtr->offscreenPtr;
  28.         for (i=0; i<gNumRows; i++)
  29.         {
  30.             for (j=0; j<gNumCols; j++)
  31.             {
  32.                 if (gBoard[i][j]<kSelectedPiece)
  33.                 {
  34.                     theBoard.boardData[i][j]=gBoard[i][j];
  35.                     gBoard[i][j]=kEmptyTile;
  36.                 }
  37.             }
  38.         }
  39.         SetPortToOffscreenWindow(offscreenWorldPtr);
  40.         DrawTheMainWindow(theWindow, theDepth);
  41.         SetPortToOnscreenWindow(theWindow, offscreenWorldPtr);
  42.         boundsRect=theWindow->portRect;
  43.         OffsetRect(&boundsRect, -boundsRect.left, -boundsRect.top);
  44.         HorizontalBarsWipe(offscreenWindowPtr, theWindow, boundsRect);
  45.         SetWindowOffscreenNeedsUpdate(theWindow, FALSE);
  46.         for (k=0; k<12; k++)
  47.         {
  48.             refreshIndex=0;
  49.             for (i=0; ((i<gNumRows) && (refreshIndex<5)); i++)
  50.             {
  51.                 for (j=0; ((j<gNumCols) && (refreshIndex<5)); j++)
  52.                 {
  53.                     if (theBoard.boardData[i][j]==gPiecesPlayed[k])
  54.                     {
  55.                         refresh[k][refreshIndex].h=i;
  56.                         refresh[k][refreshIndex++].v=j;
  57.                     }
  58.                 }
  59.             }
  60.         }
  61.         for (k=0; k<12; k++)
  62.         {
  63.             for (i=0; i<5; i++)
  64.             {
  65.                 gBoard[refresh[k][i].h][refresh[k][i].v]=gPiecesPlayed[k];
  66.             }
  67.             RefreshTiles(theWindow, refresh[k], 5, FALSE, FALSE);
  68.             DoSound(sound_placepiece, (k<11));
  69.             CompactMem(maxSize);
  70.         }
  71.         ShowCursor();
  72.     }
  73.     DoSound(sound_wingame, TRUE);
  74.     DisplayTheAlert(kPlainAlert, (GetWindowRealDepth(0L)>2) ? kWinAlertColor : kWinAlertBW,
  75.         "\p", "\p", "\p", "\p", (UniversalProcPtr)OneButtonFilter);
  76. }
  77.